//
//  UIButton+Common.m
//  M800Project
//
//  Created by 姚宗超 on 14/11/11.
//  Copyright (c) 2014年 姚宗超. All rights reserved.
//

#import "UIButton+Biz.h"
#import "NSString+Common.h"

@implementation UIButton (Biz)

- (void)setImage:(UIImage *)image withTitle:(NSString *)title font:(UIFont *)font forState:(UIControlState)stateType
{
    //UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right)
    CGSize titleSize = [title sizeWithFont:font byHeight:font.lineHeight];
    self.width = titleSize.width+image.size.width;
    self.height = (titleSize.height > image.size.height) ? titleSize.height : image.size.height;

    [self setImage:image forState:stateType];
    [self.titleLabel setBackgroundColor:[UIColor clearColor]];
    [self.titleLabel setFont:font];
    [self setTitle:title forState:stateType];
}

@end
